#include <stdio.h>
#include <stdlib.h>

typedef struct linknode
{
	int data;
	struct linknode *next;
}link_node;

link_node *creat();
int linkinsert(link_node *H,int arrnum);
int hashfind(link_node *H,int inputnum);

int main(int argc, const char *argv[])
{
	int arr[8]={11,33,55,77,99,66,44,22};
	link_node *hasharr[16];
	int temp=16;
	int hashkey=0;
	int i=0;
	for(i=0;i<16;i++)
	{
		hasharr[i]=creat();
	}
	for(i=0;i<8;i++)
	{
		hashkey=arr[i]%temp;
		linkinsert(hasharr[hashkey],arr[i]);
	}

	int myinputnum;
	printf("plz input your will find num\n");
	printf(">>>>");
	scanf("%d",&myinputnum);
	int findkey=myinputnum%temp;
	int flag=hashfind(hasharr[findkey],myinputnum);
	if(flag<0)
	{
		printf("error\n");
	}
	else
	{
		printf("success\n");
	}
	
	return 0;
}

link_node *creat()
{
	link_node *H=(link_node *)malloc(sizeof(link_node));
	H->data=-1;
	H->next=NULL;

	return H;
}

int linkinsert(link_node *H,int arrnum)
{
	link_node *p=(link_node *)malloc(sizeof(link_node));
	p->data=arrnum;
	p->next=H->next;

	H->next=p;
	
	return 0;
}

int hashfind(link_node *H,int inputnum)
{
	int flag=-1;
	while(H->next!=NULL)
	{
		H=H->next;
		if(H->data==inputnum)
		{
			flag=1;
			break;
		}
	}

	return flag;
}
